﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminMTP.Master" AutoEventWireup="true" CodeBehind="Staff.aspx.cs" Inherits="tracnghiemonline2.Staff" %>

<%@ Import Namespace="DataAccess" %>
<%@ Import Namespace="System.Linq" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="../Ajax/JS/Staff.js"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="w3-row" id="main-admin">
        <header class="w3-padding w3-large w3-center w3-teal">NHÂN SỰ</header>
        <div class="w3-row">
            <div class="w3-third w3-padding">
                <label class="w3-teal" style="padding: 1% 3%" title="Tìm kiếm"><i class="fa fa-search"></i></label>
                <input type="text" id="find_by_name" placeholder="Nhập tên đăng nhập hoặc họ tên..." style="width: 70%; padding: 0.5%" />
            </div>
            <div class="w3-third w3-padding">
                <label class="w3-teal" style="padding: 1% 3%" title="Lọc quyền"><i class="fa fa-filter"></i></label>
                <select style="padding: 1.1%" id="find_by_role">
                    <option selected="selected" value="0">Chọn quyền</option>
                    <%var get_role = new TblManagerRoleController().FetchAll();
                      foreach (TblManagerRole role in get_role)
                      {
                    %>
                    <option value="<%=role.RoleId %>"><%=role.RoleName %></option>
                    <%} %>
                </select>
                <a id="btn_role_edit" class="w3-btn w3-teal" onclick="document.getElementById('Role_edit').style.display='block'" style="margin-bottom: 3px; display: none" title="Tùy chọn"><i class="fa fa-cogs"></i></a>
                <a onclick="document.getElementById('role_add').style.display='block'" class="w3-btn w3-teal" style="margin-bottom: 3px" title="Thêm Quyền"><i class="fa fa-plus"></i></a>
            </div>
            <div class="w3-third w3-padding">
                <a id="btn_sign_in" class="w3-btn w3-teal"><i class="fa fa-plus"></i>&nbsp;<i class="fa fa-user"></i>&nbsp;Thêm nhân viên</a>
            </div>
        </div>
        <div class="w3-responsive">
            <table id="sort_staff" class="staff-table w3-table w3-striped w3-bordered w3-border">
                <tr class="w3-teal">
                    <th>Ảnh</th>
                    <th>Tên đăng nhập</th>
                    <th>Quyền</th>
                    <th>Họ tên</th>
                    <th>Ngày sinh</th>
                    <th>Giới tính</th>
                    <th>SĐT</th>
                    <th>Email</th>
                    <th>Kích hoạt</th>
                    <th>Xóa</th>
                </tr>
                <%var get_staff = new TblManagerController().FetchAll();
                  foreach (TblManager staff in get_staff)
                  {
                      if (staff.ManagerId == int.Parse(Session["admin_id"].ToString()))
                          continue;
                %>
                <tr id="staff<%=staff.ManagerId %>" class="staff">
                    <td class="w3-hide staff_id"><%=staff.ManagerId %></td>
                    <td class="staff-img">
                        <img src="../Content/avatar/<%=staff.Avatar %>" class="w3-circle" /></td>
                    <td><%=staff.ManagerName %></td>
                    <td>
                        <select style="padding: 1.1%" class="change_role">
                            <%
                      foreach (TblManagerRole role in get_role)
                      { %>
                            <%if (staff.Role == role.RoleId)
                              {%>
                            <option value="<%=role.RoleId %>" selected="selected"><%=role.RoleName %></option>
                            <%}
                              else
                              { %>
                            <option value="<%=role.RoleId %>"><%=role.RoleName %></option>
                            <%}
                      } %>
                        </select>
                    </td>
                    <td><%=staff.FullName %></td>
                    <td><%=DateTime.Parse(staff.Birthday.ToString()).Day+"/"+DateTime.Parse(staff.Birthday.ToString()).Month+"/"+DateTime.Parse(staff.Birthday.ToString()).Year %></td>
                    <td><%if (staff.Sex == true)
                          { %>Nam<%}
                          else
                          {%>Nữ<%} %></td>
                    <td><%=staff.Phone %></td>
                    <td><%=staff.Email %></td>
                    <%if (staff.Active == true)
                      {%>
                    <td class="option-btn">
                        <i class="on1 fa fa-toggle-on w3-text-teal w3-animate-opacity"></i>
                    </td>
                    <%}
                      else
                      { %>
                    <td class="option-btn">
                        <i class="on1 fa fa-toggle-on w3-text-red w3-animate-opacity fa-rotate-180 off "></i>
                    </td>
                    <%} %>
                    <td class="option-btn"><i class="del_staff fa fa-trash"></i></td>
                </tr>
                <%} %>
            </table>
        </div>
    </div>
    <div id="sign-in-modal" class="w3-modal w3-hide-medium w3-hide-small">
        <div class="sign-in-modal w3-modal-content w3-card-8 w3-animate-bottom" style="width: 42%">
            <header class="w3-padding w3-teal w3-center">
                <p style="font-size: 20px">Thêm mới nhân viên</p>
            </header>
            <div class="w3-row w3-padding w3-text-black">
                <div class="w3-row w3-padding">
                    <p class="w3-small">Những thông tin có đánh dấu <i class="fa fa-star w3-text-red w3-small"></i>&nbsp;là bắt buộc nhập.</p>
                </div>
                <div class="w3-row w3-padding">
                    <input style="width: 91%" id="txt_name" name="fullname" type="text" placeholder="Họ tên đầy đủ" autofocus="autofocus" required="required" /><i class="fa fa-star w3-text-red w3-padding-left w3-small"></i>
                </div>
                <div id="error" class="w3-hide"></div><div id="error_msg" class="w3-text-red w3-row w3-padding"></div>
                <div class="w3-row w3-padding">
                    <input style="width: 91%" id="txt_username" name="username" type="text" placeholder="Tên đăng nhập" autofocus="autofocus" required="required" /><i class="fa fa-star w3-text-red w3-padding-left w3-small"></i>
                </div>
                <div class="w3-row w3-padding">
                    <input style="width: 91%" id="txt_pass" name="pass" type="password" placeholder="Mật khẩu" autofocus="autofocus" required="required" /><i class="fa fa-star w3-text-red w3-padding-left w3-small"></i>
                </div>
                <div class="w3-row w3-padding">
                    <input style="width: 91%" id="txt_repass" name="re-pass" type="password" placeholder="Nhập lại mật khẩu" autofocus="autofocus" required="required" /><i class="fa fa-star w3-text-red w3-padding-left w3-small"></i>
                </div>
                <div class="w3-row w3-padding">
                    <input style="width: 91%" id="txt_email" name="email" type="email" placeholder="Địa chỉ email" autofocus="autofocus" required="required" /><i class="fa fa-star w3-text-red w3-padding-left w3-small"></i>
                </div>
                <div class="w3-row w3-padding">
                    <input style="width: 91%" id="txt_phone" name="phone" type="text" placeholder="Số điện thoại" autofocus="autofocus" />
                </div>
                <div class="w3-row w3-padding">
                    <div class="w3-third w3-padding-right">
                        <select id="day">
                            <option value="0" selected="selected">Ngày</option>
                            <%for (int i = 1; i <= 31; i++)
                              { %>
                            <option value="<%=i %>"><%=i %></option>
                            <%} %>
                        </select>
                    </div>
                    <div class="w3-third w3-padding-right">
                        <select id="month">
                            <option value="0" selected="selected">Tháng</option>
                            <%for (int i = 1; i <= 12; i++)
                              { %>
                            <option value="<%=i %>"><%=i %></option>
                            <%} %>
                        </select>
                    </div>
                    <div class="w3-third w3-padding-right">
                        <select id="year">
                            <option value="0" selected="selected">Năm sinh</option>
                            <%
                                int get_year = DateTime.Now.Year - 10;
                                for (int i = get_year; i >= get_year - 40; i--)
                                {
                            %>
                            <option value="<%=i %>"><%=i %></option>
                            <%} %>
                        </select>
                    </div>
                </div>
                <div class="w3-row w3-padding">
                    <div class="w3-third">Giới tính:</div>
                    <div class="radio w3-third">
                        <input type="radio" name="sex" checked="checked" value="1" id="male" /><label for="male">Nam</label>&nbsp;
                        <input type="radio" name="sex" value="0" id="female" /><label for="female">Nữ</label>
                    </div>
                </div>
                <%--<div class="w3-row w3-padding w3-small">
                    <p>Bằng việc click vào nút <b>Đăng ký</b> bạn đã đồng ý</p>
                    <p><b><a href="javascript:;" class="w3-text-brown w3-hover-text-teal">Điều khoản sử dụng</a></b></p>
                </div>--%>
                <div class="w3-row">
                    <div class="w3-half"><a id="btn_add_staff" href="javascript:;" class="w3-btn w3-teal" style="width: 100%">Thêm</a></div>
                    <div class="w3-half"><a href="javascript:;" class="w3-btn w3-red" style="width: 100%" onclick="document.getElementById('sign-in-modal').style.display='none'">&times;&nbsp;Huỷ</a></div>
                </div>
            </div>
        </div>
    </div>
    <div id="xoanhanvien" class="w3-modal">
        <div id="del_id" class="w3-hide"></div>
        <div class="w3-modal-content w3-animate-top w3-card-8 w3-teal" style="width: 60%">
            <header class="w3-padding w3-center">
                <span onclick="this.parentElement.parentElement.parentElement.style.display='none'" class="w3-closebtn">&times;</span>
                <p class="w3-xlarge">Những tài liệu và tập tin liên quan đến người dùng này sẽ bị xóa theo, bạn có chắc chắn muốn xóa?</p>
            </header>
            <div class="w3-row w3-padding w3-center">
                <a id="staff_del_yes" class="w3-btn w3-teal w3-border w3-border-white"><i class="fa fa-trash"></i>&nbsp;Xóa</a>
                <a onclick="document.getElementById('xoanhanvien').style.display='none'" class="w3-btn w3-teal w3-border w3-border-white"><i class="fa fa-times"></i>&nbsp;Hủy</a>
            </div>
        </div>
    </div>
    <div id="role" class="w3-modal">
        <div id="confirm_id" class="w3-hide"></div>
        <div id="confirm_role" class="w3-hide"></div>
        <div class="w3-modal-content w3-animate-top w3-card-8 w3-teal" style="width: 30%">
            <header class="w3-padding w3-center">
                <span onclick="document.getElementById('role').style.display='none'" class="w3-closebtn">&times;</span>
                <p class="w3-xlarge">Xác nhận</p>
            </header>
            <div class="w3-row w3-padding w3-center">
                <a id="role_yes" class="w3-btn w3-teal w3-border w3-border-white"><i class="fa fa-check w3-small"></i>&nbsp;Đồng ý</a>
                <a onclick="document.getElementById('role').style.display='none'" class="w3-btn w3-teal w3-border w3-border-white"><i class="fa fa-times"></i>&nbsp;Hủy</a>
            </div>
        </div>
    </div>
    <div id="Role_edit" class="w3-modal">
        <div class="w3-modal-content w3-animate-top w3-card-8 w3-teal" style="width: 30%">
            <header class="w3-padding w3-center">
                <span onclick="this.parentElement.parentElement.parentElement.style.display='none'" class="w3-closebtn">&times;</span>
                <p class="w3-xlarge">Chỉnh sửa Quyền</p>
            </header>
            <div class="w3-padding w3-row">
                <input type="text" required="required" value="" id="txt_role_edit" placeholder="Tên quyền" autofocus="autofocus" style="width: 100%; padding: 0.5%; color: black" />
            </div>
            <div class="w3-row w3-padding w3-center">
                <a id="btn_role_edited" class="w3-btn w3-teal w3-border w3-border-white"><i class="fa fa-save"></i>&nbsp;Lưu</a>
                <a id="btn_role_del" class="w3-btn w3-teal w3-border w3-border-white"><i class="fa fa-trash"></i>&nbsp;Xóa</a>
            </div>
        </div>
    </div>
    <div id="role_add" class="w3-modal">
        <div class="w3-modal-content w3-animate-top w3-card-8 w3-teal" style="width: 30%">
            <header class="w3-padding w3-center">
                <span onclick="this.parentElement.parentElement.parentElement.style.display='none'" class="w3-closebtn">&times;</span>
                <p class="w3-xlarge">Thêm mới quyền</p>
            </header>
            <div class="w3-padding w3-row">
                <input type="text" id="txt_role_add" required="required" placeholder="Tên Quyền" autofocus="autofocus" style="width: 100%; padding: 0.5%; color: black" />
            </div>
            <div class="w3-row w3-padding w3-center">
                <a id="btn_role_add" class="w3-btn w3-teal w3-border w3-border-white"><i class="fa fa-save"></i>&nbsp;Lưu</a>
            </div>
        </div>
    </div>

</asp:Content>
